
const num1 = BigInt('1')
const num2 = BigInt('2')
console.log(typeof num1)    //bigint
console.log((num1 + num2))  //3n
console.log((num1 - num2))  //-1n
console.log((num1 * num2))  //2n
console.log((num1 / num2))  //0n
console.log((num1 % num2))  //1n
console.log((2n == 2))  //false,因为数据类型不同

//可以将Number类型的转为BigInt
console.log((2n === BigInt(2)))  //TRUE
//可以将2n转为Number
console.log((Number(2n) === 2)) //true


const aa = BigInt('88888888888888888888888888888888')
const bb = BigInt('11111111111111111111111111111111')
const aa1 = BigInt(88888888888888888888888888888888)
const bb1 = BigInt(11111111111111111111111111111111)
console.log((aa + bb).toString(), 'bigInt') //输出正常 99999999999999999999999999999999
console.log((aa1 + bb1), 'bigInt')  //失真，BigInt参数最好是字符串,如果是数字，超出-2^53+1~2^53-1这个范围会失真

const aa11 = BigInt('123bb')  //报错
const aa22 = BigInt('123bb')  ////报错
console.log(aa11+aa22) 